

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'node:path';



// https://vitejs.dev/config/
export default defineConfig({
  build: {
    sourcemap: false,
  },
  optimizeDeps: {
    include: ['echarts'], // 将 ECharts 加入到优化依赖中
  },
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      '@': resolve('src')
    }
  },
  server: {
    port: "5174",
    open: true,
    // proxy: {
    //   "/api": {
    //     target: "http://dt:8005",
    //     changeOrigin: true,
    //     rewrite: (path) => path.replace(/^\/api/, ""),
    //   },
    //   "/pic": {
    //     target: "http://dist-stu:8004",
    //     changeOrigin: true,
    //     rewrite: (path) => path.replace(/^\/pic/, ""),
    //   },
    //   "/cgi/data.php": {
    //     target: "http://cgq.hmsensor.com",
    //     changeOrigin: true,
    //   },
    //   "apg/cn/demo.html": {
    //     target: "http://dt:80",
    //     changeOrigin: true,
    //     rewrite: (path) => path.replace(/^\/apg/, ""),
    //   }
    // },
    proxy: {
      "/api": {
        // target: "http://47.93.162.187:8005",
        target: "http://localhost:8005",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
      "/pic": {
        target: "http://115.24.173.26:8002",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/pic/, ""),
      },
      "/cgi/data.php": {
        target: "http://cgq.hmsensor.com",
        changeOrigin: true,
      },
      "apg/cn/demo.html": {
        target: "http://localhost:80",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/apg/, ""),
      }
    },
  },
});

